﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using YXChatFormClient.Dtos;
using YXChatFormClient.Dtos.Buddy;
using YXChatFormClient.Utility;

namespace YXChatFormClient.UserControls
{
    public partial class UC_ChatsContainer : UserControl
    {
        public UC_ChatsContainer()
        {
            InitializeComponent();
        }

        private void UC_ChatsContainer_Load(object sender, EventArgs e)
        {
            InitChatsItemData();
        }
        public List<ChatRecordAccountDto> ChatRecordAccounts { get; set; } = new List<ChatRecordAccountDto>();
        private void InitChatsItemData()
        {
            ChatRecordAccounts.Reverse();
            foreach (var item in ChatRecordAccounts)
            {
                UC_ChatItem chatItem = new UC_ChatItem()
                {
                    ChatRecordAccount = item
                };
                chatItem.ChatClick += ChatItem_ChatClick;            
                chatItem.Dock = DockStyle.Top;
                this.Controls.Add(chatItem);
            }
        }
        public event UC_ChatItem.ChatClickHandler ChatClick;
        public void ChatItem_ChatClick(object sender, EventArgs e, ChatRecordAccountDto chatRecord)
        {
            ChatClick(sender,e, chatRecord);
        }

        private void UC_ChatsContainer_Paint(object sender, PaintEventArgs e)
        {
            PaintHelper.PaintBorder(e, this.ClientRectangle, Color.White,
                Color.White, Color.FromArgb(214, 214, 214), Color.White);
        }
    }
}
